package com.api.shopapi.service.impl;


import com.api.shopapi.entity.SendMessage;
import com.api.shopapi.entity.dto.SendMessageDTO;
import com.api.shopapi.mapper.SendMessageMapper;
import com.api.shopapi.service.SendMessageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("SendMessageServiceImplOne")
public class SendMessageServiceImpl implements SendMessageService {

    @Autowired
    private SendMessageMapper sendMessageMapper;

    @Override
    public int insert(SendMessage sendMessage){
        return sendMessageMapper.insert(sendMessage);
    }

    @Override
    public SendMessage getBySendMessageCode(String sendMessageCode) {
        return sendMessageMapper.getBySendMessageCode(sendMessageCode);
    }

    @Override
    public PageInfo<SendMessageDTO> getPageList(int pageIndex, int pageSize, String startTime, String endTime,String governmentCode) {
        PageHelper.startPage(pageIndex, pageSize);
        List<SendMessageDTO> sendMessages = sendMessageMapper.getPageList(startTime,endTime,governmentCode);
        PageInfo<SendMessageDTO> pageInfo = new PageInfo<>(sendMessages);
        return pageInfo;
    }

}
